declare(strict_types=1);

namespace App\Service\Impl;

use App\Model\Dao\<?=$modelName?>Dao;
use App\Service\I<?=$modelName?>Service;
use App\Utils\CustomUtils;
use Hyperf\Di\Annotation\Inject;

class <?=$modelName?>ServiceImpl implements I<?=$modelName?>Service
{
    /**
    * @Inject()
    * @var <?=$modelName?>Dao
    */
    private $<?=lcfirst($modelName)?>Dao;

    /**
    * @param $data
    * @return mixed
    */
    public function list($data)
    {
        return $this-><?=lcfirst($modelName)?>Dao->list($data);
    }

    /**
    * @param $configId
    * @return mixed
    */
    public function get($id)
    {
        return CustomUtils::zkReturnSuccessData($this-><?=lcfirst($modelName)?>Dao->get($id));
    }

    /**
    * @param $data
    * @param $userName
    * @return mixed
    */
    public function add($data, $userName)
    {
        $result = $this-><?=lcfirst($modelName)?>Dao->add($data, $userName);
        if ($result) {
            return CustomUtils::zkReturnSuccessData();
        } else {
            return CustomUtils::zkReturnFailedData();
        }
    }

    /**
    * @param $data
    * @param $userName
    * @return mixed
    */
    public function edit($data, $userName)
    {
        $result = $this-><?=lcfirst($modelName)?>Dao->edit($data, $userName);
        if ($result >= 0) {
            return CustomUtils::zkReturnSuccessData();
        } else {
            return CustomUtils::zkReturnFailedData();
        }
    }

    /**
    * @param $configId
    * @return mixed
    */
    public function del($id)
    {
        $result = $this-><?=lcfirst($modelName)?>Dao->del($id);
        if ($result) {
            return CustomUtils::zkReturnSuccessData();
        } else {
            return CustomUtils::zkReturnFailedData();
        }
    }
}